<?php
	require_once '../libs/app.config.php';
	require_once INCLUDE_PATH.'template.config.php';
	require_once 'head.php';
	$charset?null:$charset='cn';
	$charset  = $tpm->escape($charset);


	if($id){
		$sql = sprintf('select distinct r.orderId, r.time, r.location, r.detail from order_records r, orders o  where  r.orderId="%s"',$id, $charset);
		$query = $tpm->query($sql);
		$totals = $tpm->num_rows($query);
		$tpn = new Page();
		
		$sql2 = sprintf('select * from orders o where o.orderId="%s"',$id,$charset);
		$query = $tpm->query($sql2);
		if($tpm->affected_rows($query)){
			$latest = $tpm->fetch_array($query);
			$tpl->assign("latest",$latest);
		}
	}

//print_r($latest);

	if($charset=='en'){
		$tpn->pageft($totals,10);
		$sql = $sql." limit ".$tpn->getfirstcount().",10";
		$query = $tpm->query($sql);
		while($row = $tpm->fetch_array($query)) $list[]=$row;
		$tpl->assign("list",$list);
		$tpl->assign("page_nav",$tpn->getpagenav());
		$tpl->display("latest_en.html");
	}else{
		$tpn->pageft_cn($totals,10);
		$sql = $sql." limit ".$tpn->getfirstcount().",10";
		$query = $tpm->query($sql);
		while($row = $tpm->fetch_array($query)) $list[]=$row;
		$tpl->assign("list",$list);
		$tpl->assign("page_nav",$tpn->getpagenav());
		$tpl->display("show.html");
	}
?>